/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.Graphics;
import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JPanel;
import model.Field;

/**
 * De klasse FieldPanel is verantwoordelijk voor:
 *      de het speelveld TEKENNEN
 * 
 * Field heeft geen kennis van andere klassen
 * 
 * Author Misja, Bob.
 */
public class FieldPanel extends JPanel {

    private ArrayList<Field> fields;

    
    public FieldPanel() {
        initComponents();
    }
    
    /*
     * Deze methode tekent alle vanuit de lijst van object
     * hij gaan deze 1 voor 1 doorheen en roept de teken methode van ze aan
     */
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        if (fields != null) {
            Iterator<Field> it = fields.iterator();
            while (it.hasNext()) {
                Field f = it.next();
                f.draw(g);
            }
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setPreferredSize(new java.awt.Dimension(600, 600));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 625, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 625, Short.MAX_VALUE)
        );

        getAccessibleContext().setAccessibleName("");
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

    /**
     * @param fields the fields to set
     */
    public void setFields(ArrayList<Field> field) {
        this.fields = field;
    }
    
}
